use serde::Deserialize;
use std::fs;

#[derive(Deserialize, Debug)]
pub struct Config {
    phoenix: Phoenix,
}

#[derive(Deserialize, Debug)]
pub struct Phoenix {
    exepath: String,
    exename: String,
    account: String,
    password: String,
    delay: u32,
}

pub fn load() -> Config {
    let toml = fs::read_to_string("conf.toml").expect("Failed to parse config file.");
    let config: Config = toml::from_str(&toml).expect("Failed to analyze config.");
    config
}

pub fn exepath(config: &Config) -> &str {
    &config.phoenix.exepath
}
pub fn exename(config: &Config) -> &str {
    &config.phoenix.exename
}
pub fn account(config: &Config) -> &str {
    &config.phoenix.account
}
pub fn password(config: &Config) -> &str {
    &config.phoenix.password
}
pub fn delay(config: &Config) -> &u32 {
    &config.phoenix.delay
}